package com.hsy.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import java.time.LocalDateTime;
import java.util.Date;

public class User {

    // 用户id
    private Long userId;
    // 部门id
    private Long deptId;
    // 用户账号
    /*
        由于用了Jackson 所以后端的属性名要用@JsonProperty重新指定与前端传来的一致才行
     */
    @JsonProperty("username")
    private String userNumber;
    // 用户名称
    @JsonProperty("nickname")
    private String userName;
    // 密码
    @JsonProperty("password")
    private String password;
    // 电话号码
    @JsonProperty("phone")
    private String telephone;
    // 账号状态
    private String status;
    // 头像地址
    private String avatarAddress;
    // 创建时间
    // 解决 jackson默认不支持java8 LocalDateTime的序列化和反序列化
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;
    // 更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime updateTime;
    public User(){}

    public User(String userNumber, String userName, String password, String telephone, String avatarAddress) {
        this.userNumber = userNumber;
        this.userName = userName;
        this.password = password;
        this.telephone = telephone;
        this.avatarAddress = avatarAddress;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public String getUserNumber() {
        return userNumber;
    }

    public void setUserNumber(String userNumber) {
        this.userNumber = userNumber;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getAvatarAddress() {
        return avatarAddress;
    }

    public void setAvatarAddress(String avatarAddress) {
        this.avatarAddress = avatarAddress;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public User(String userNumber, String userName, String password, String telephone) {
        this.userNumber = userNumber;
        this.userName = userName;
        this.password = password;
        this.telephone = telephone;
    }

    public User(Long userId, Long deptId, String userNumber, String userName, String telephone, String status) {
        this.userId = userId;
        this.deptId = deptId;
        this.userNumber = userNumber;
        this.userName = userName;
        this.telephone = telephone;
        this.status = status;
    }
}